package com.nip.workmanager.common.utilities;

public class UtilitiesObjectId {

	/**
	 * Make Id
	 * 
	 * @param biggestId
	 *            Id biggest
	 * @param extension
	 *            Extension of Id
	 * @param length
	 *            length
	 * @return id
	 */
	public static String MakeObjecId(String biggestId, String extension,
			int length) {
		int lenghtExtension = extension.length();

		// If first id
		if (biggestId == null) {
			String numberIdTemp = "1";
			for (int i = 1; i < length - extension.length(); i++) {
				numberIdTemp = "0" + numberIdTemp;
			}
			return extension + numberIdTemp;
		}

		String idNumber = biggestId.substring(lenghtExtension);
		int numberId = Integer.parseInt(idNumber);
		numberId += 1;
		idNumber = String.valueOf(numberId);
		String objectId = "0";
		for (int i = 1; i < length - lenghtExtension - idNumber.length(); i++) {
			objectId = '0' + objectId;
		}
		return extension + objectId + idNumber;

	}
}
